package com.tjshop.android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.tjshop.android.R;
import com.tjshop.android.model.MyListItem;
import java.util.List;

public class RegionAdapter extends BaseAdapter {
	List<MyListItem> list;
	private Context mContext;

	public RegionAdapter(Context context, List<MyListItem> clist) {
		list = clist;
		this.mContext = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int i) {
		return list.get(i);
	}

	@Override
	public long getItemId(int i) {
		return i;
	}

	@Override
	public View getView(final int i, View convertView, ViewGroup viewGroup) {
		ViewHolder viewHolder = null;
		if (null == convertView) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.region_item, null);

			viewHolder.name = (TextView) convertView
					.findViewById(R.id.item_title);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.name.setText(list.get(i).getName());

		return convertView;
	}

	private static class ViewHolder {
		TextView name;
	}

}
